package com.mall.db.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.db.dao.MemberDao;
import com.mall.db.domain.Member;
import org.springframework.stereotype.Service;

@Service
public class MemberService extends ServiceImpl<MemberDao, Member> {


    /*@Autowired
    private  MemberDao md;

    public Member get(Member member){

        List<Member> list = md.find(member);
        member = list.size()> 0?list.get(0):null;
        return member;

    }

    public Map<String,Object> toLogin(String loginName, String password, String code,
                                      HttpServletRequest req, ModelAndView mav){

        Map<String,Object> map = new HashMap<>();
        //获取session
        HttpSession session = req.getSession();
        //获取验证码

        String imgCode = session.getAttribute("sessionCode").toString();


        //销毁session
        session.removeAttribute("sessionCode");

        if (StringUtils.isEmpty(code)||!imgCode.equals(code)){
            map.put("is",false);
            map.put("msg","验证码错误6");
            return map;
        }
        //

        Member m = new Member();

        m.setLoginName(loginName);

        m = this.get(m);


        if (m == null || StringUtils.isEmpty(loginName)){
            map.put("is",false);
            map.put("msg","登录账号不存在");
        }else {
            //验证码
            if (m.getPassword().equals(StringUtil.md5(password)) && !StringUtils.isEmpty(password)){
                map.put("is",true);
                map.put("msg","登陆成功");
                map.put("userName",m.getUserName());
                m.setPassword("");
                session.setAttribute("member",m);//存入会话





                mav.addObject("b",m);
                System.out.println("-->>"+m.getUserName());
                mav.setViewName("/views/index");






               *//* String role = m.getRoleIds();
                List<Integer> rids = JSON.parseArray(role,Integer.class);
                List<Menu> menus = ed.findMenuByRid(rids,"btn");
                Set<String> prims = new HashSet<>();
                for (Menu menu:menus) {
                    prims.add(menu.getRemark());
                }
                session.setAttribute("prims",prims);

                *//*

            }else {
                map.put("is",false);
                map.put("msg","密码错误");
            }

        }

        return map;

    }*/


}
